package com.kcs.common.utils;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class md5
{

    public md5()
    {
    }

    public static String hex(byte array[])
    {
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < array.length; i++)
            sb.append(Integer.toHexString(array[i] & 0xff | 0x100).toUpperCase().substring(1, 3));

        return sb.toString();
    }

    public static String encrypt(String message)
    {
        try
        {
            MessageDigest md = MessageDigest.getInstance("MD5");
            return hex(md.digest(message.getBytes("CP1252")));
        }
        catch(NoSuchAlgorithmException nosuchalgorithmexception) { }
        catch(UnsupportedEncodingException unsupportedencodingexception) { }
        return null;
    }

    public static void main(String[] args) {
    	
    	System.out.println("ddd");
//        md5 test = new md5();
//        String output = test.encrypt("p@s$w0rD;K1b");
//        System.out.println("output --->>> "+output);
    }
}
